package flatlandRPGTest;

import flatlandRPG.Player;
import flatlandRPG.Building;
import org.lwjgl.util.vector.Vector2f;
import flatlandRPG.CollisionManager;
import student.*;

// -------------------------------------------------------------------------
/**
 * Tests the collision manager class.
 *
 * @author evant
 * @version Apr 17, 2011
 */
public class CollisionManagerTest
    extends TestCase
{
    private CollisionManager testCollisionManager;


    public void setUp()
    {
        testCollisionManager = new CollisionManager();
    }


    // ----------------------------------------------------------
    /**
     * Tests that the collision manager correctly registers collisions and the
     * player is moved back because of it.
     */
    public void testDoLogic()
    {
        Player player = new Player();
        Building building =
            new Building(new Vector2f(0, 0), new Vector2f(0, 1), new Vector2f(
                1,
                1));
        player.setLocation(new Vector2f(-1, -1));

        testCollisionManager.add(player);
        testCollisionManager.add(building);

        player.move(new Vector2f(0, 0));
        testCollisionManager.doLogic();

        Vector2f playerLocation = player.getLocation();

        assertEquals(-1, playerLocation.getX(), 0.0001);
        assertEquals(-1, playerLocation.getY(), 0.0001);
    }
}
